package main

import (
	"context"
	"fmt"
	"time"

	"github.com/ulule/limiter/v3"
	"github.com/ulule/limiter/v3/drivers/store/memory"
)

func main() {
	rate := limiter.Rate{
		Period: 1 * time.Hour,
		Limit:  10,
	}

	store := memory.NewStore()

	instance := limiter.New(store, rate)

	key := "user_1"
	c, err := instance.Get(context.TODO(), key)
	if err != nil {
		panic(err)
	}

	fmt.Println(c)

	for i := 0; i < 10; i++ {
		c, _ = instance.Get(context.TODO(), key)
		fmt.Println(c.Reached)
	}
}

// {10 9 1599623062 false}
// false
// false
// false
// false
// false
// false
// false
// false
// false
// true
